{extend name="../../../view/public/base" /}
{block name="body"}
<div class="bw-container">
    <div class="bw-main">
        <div class="layui-row layui-col-space15">

            <div class="layui-col-md12">
                <div class="layui-card">
                    <div class="layui-collapse" lay-filter="test">
                        <div class="layui-colla-item">
                            <h2 class="layui-colla-title"><i class="layui-icon">&#xe615;</i>查询条件</h2>
                            <div class="layui-colla-content"  >



                                <br>

                                <div class="demoTable layui-form ">
                                    {if empty($tab_name)}
                                    <div class="layui-inline">
                                        <label class="layui-form-label">配置分类：</label>
                                        <div class="layui-inline" >
                                            <select name="tab_id" id="tab_id" lay-verify="required" >

                                                <option value="" selected="">请选择</option>
                                                {volist name="tab" id="vo"}
                                                <option value="{$vo.id}">{$vo.title}</option>

                                                {/volist}


                                            </select>
                                        </div>
                                    </div>
                                    {/if}
                                    <div class="layui-inline">
                                        <label class="layui-form-label">配置名称：</label>
                                        <div class="layui-inline">
                                            <input class="layui-input"  name="info" id="info" autocomplete="off" placeholder="配置名称">
                                        </div>
                                    </div>
                                    <div class="layui-inline">
                                        <label class="layui-form-label">配置标识：</label>
                                        <div class="layui-inline">
                                            <input class="layui-input"  name="config_name" id="config_name" autocomplete="off" placeholder="配置标识">
                                        </div>
                                    </div>
                                    <div class="layui-inline">
                                        <label class="layui-form-label">租户ID：</label>
                                        <div class="layui-inline">
                                            <input class="layui-input"  name="member_id" id="member_ids" autocomplete="off" placeholder="租户ID">
                                        </div>
                                    </div>
                                    <div class="layui-inline">
                                        <label class="layui-form-label">租户：</label>
                                        <div class="layui-inline">
                                            <input class="layui-input"  name="nickname" id="nickname" autocomplete="off" placeholder="租户关键词">
                                        </div>
                                    </div>
                                    <br><br>
                                    <!--<div class="layui-inline">-->
                                    <!--<label class="layui-form-label">时间范围：</label>-->

                                    <!--<div class="layui-input-inline">-->
                                    <!--<input type="text" class="layui-input time-picker" id="beginTime" placeholder="最小时间">-->
                                    <!--</div>-->
                                    <!--</div>-->
                                    <!--~-->
                                    <!--<div class="layui-input-inline">-->
                                    <!--<input type="text" class="layui-input time-picker" id="endTime" placeholder="最大时间">-->
                                    <!--</div>-->
                                    <div class="layui-inline">
                                        <label class="layui-form-label">所属应用：</label>
                                        <div class="layui-input-inline">
                                            <select name="dir" id="miniapp_name" lay-filter="miniapp_name" >
                                                <option value="">请选择</option>
                                                {volist name="miniapp" id="vo"  key="k"}
                                                <option value="{$vo.dir}" >{$vo.title}</option>
                                                {/volist}
                                            </select>

                                        </div>
                                    </div>
                                    <div class="layui-inline">
                                        <label class="layui-form-label">配置范围：</label>
                                        <div class="layui-input-inline">
                                            <select name="scopes" id="scopes" lay-verify="required" >
                                                <option value="">请选择</option>
                                                <option value="common">平台</option>
                                                <!--<option value="admin">管理员</option>-->
                                                <option value="member">租户</option>
                                            </select>
                                        </div>
                                    </div>
                                    <div class="layui-inline">
                                        <label class="layui-form-label">是否显示：</label>
                                        <div class="layui-input-inline">
                                            <select name="status" id="status" lay-verify="required" >
                                                <option value="">请选择</option>
                                                <option value="0">显示</option>
                                                <option value="1">隐藏</option>
                                            </select>
                                        </div>
                                    </div>

                                    <div class="layui-inline">
                                        <div class="layui-input-inline">
                                            &nbsp&nbsp&nbsp
                                            <button class="layui-btn layui-btn-sm   layui-btn-warm" onclick="reload()">搜索</button>
                                            <button class="layui-btn layui-btn-sm" onclick="reset()">重置</button>
                                        </div>
                                    </div>

                                    <br><br>
                                    <!--<button class="layui-btn" onclick="reload()">搜索</button>-->
                                    <!--<button class="layui-btn" onclick="reset()">重置</button>-->

                                </div>




                            </div>
                        </div>
                    </div>




                </div>
            </div>

            {if empty($type)}
            <div class="layui-col-md12">
                <div class="layui-card">


                    <div class="layui-tab layui-tab-brief" lay-filter="docDemoTabBrief">
                        <ul class="layui-tab-title ">
                            <li class="layui-this">全部</li>
                            <li>系统配置</li>
                            <li>插件配置</li>
                            <li>应用配置</li>
                            <li>其他配置</li>
                        </ul>
                    </div>


                </div>
            </div>
            {/if}

            <div class="layui-col-md12">
                <div class="layui-card">


                    <!-- 列表上面按钮 -->
                    <script type="text/html" id="toolbarDemo">
                        <div class="layui-btn-container tbtn">
                            <button class="layui-btn layui-btn-danger layui-btn-sm" type="button" onclick="del('all')"><i class="layui-icon">&#xe640;</i>批量删除</button>

                            <!--<button class="layui-btn layui-btn-sm  layui-btn-normal" onclick="edit('','all')">添加配置分类</button>-->
                            <!--<button class="layui-btn layui-btn-sm  layui-btn-normal" onclick="addconfig('','all')">添加配置</button>-->
                            <button class="layui-btn layui-btn-sm" onclick="reset()">重置</button>
                            <!--            <button class="layui-btn layui-btn-sm" type="button" onclick="edit('','all','','')"><i class="layui-icon">&#xe654;</i>新增</button>-->
                            <!--        <button class="layui-btn layui-btn-primary layui-btn-sm" type="button" onclick="del('all')"><i class="layui-icon">&#xe640;</i>新增</button>-->

                        </div>
                    </script>


                    <!-- 列表 -->
                    <table class="layui-table"  lay-data="{toolbar:'#toolbarDemo',url:'{:Url('getconfiglist')}?tabid={$tab_name}&type_system={$type}',method:'post',page:true,id:'templateList'  ,limits: [10,100,200]
            ,limit: 200}" lay-filter="templateList">
                        <thead>
                        <tr>
                            <th lay-data="{type:'checkbox',fixed: 'left'}"></th>
                            <th lay-data="{field:'id', minWidth: 200, sort: true, templet: '#member_id'}">ID</th>
                            <th lay-data="{field:'config_name', sort: true, templet: '#filed'}">字段名称</th>
                            <th lay-data="{field:'info', sort: true}">配置名称</th>
                            <th lay-data="{field:'title', sort: true}">配置分类名称</th>
                            <th lay-data="{field:'tab_name', sort: true}">配置分类标识</th>
                            <th lay-data="{field:'is_show', templet: '#status2' }">是否显示</th>
                            <th lay-data="{field:'type', templet: '#type' }">配置属性</th>
                            <th lay-data="{field:'tabtype', templet: '#tabtype' }">配置类型</th>
                            <th lay-data="{field:'app_name', templet: '#app_name' }">所属应用</th>
                            <th lay-data="{field:'scopes', templet: '#scope' }">配置范围</th>
                            <th lay-data="{field:'member_id', sort: true}">租户ID</th>
                            <th lay-data="{field:'nickname', sort: true,hide:true}">租户名</th>
                            <th lay-data="{field:'sort', sort: true, edit: 'text'}">权重(可编辑)</th>
                            <th lay-data="{fixed: 'right', width:150,  align:'center', toolbar: '#barDemo'}">操作</th>
                        </tr>
                        </thead>
                    </table>
                    <script type="text/html" id="app_name">
                        {{#  if(!d.miniapp_name){ }}
                        <span class="layui-badge layui-bg-gray">无</span>
                        {{#  } else { }}
                        <span class="layui-badge layui-bg-blue"> {{d.miniapp_name}}</span>
                        {{#  } }}
                    </script>
                    <script type="text/html" id="member_id">
                        {{#  if(d.member_id == 0&&d.scopes == 'member'){ }}
                        {{d._name}} <span class="layui-badge layui-bg-cyan">租户配置</span>
                        {{#  } else if(d.member_id != 0){ }}
                        {{d._name}}
                        {{#  } else{ }}
                        {{d._name}} <span class="layui-badge layui-bg-blue">平台配置</span>
                        {{#  } }}
                    </script>
                    <script type="text/html" id="scope">
                        {{#  if(d.scopes == 'common'){ }} <span class="layui-badge layui-bg-blue">平台</span>{{#  } }}
                        {{#  if(d.scopes == 'admin'){ }}<span class="layui-badge layui-bg-blue">管理员</span>{{#  } }}
                        {{#  if(d.scopes == 'member'){ }} <span class="layui-badge">租户</span>{{#  } }}
                    </script>
                    <script type="text/html" id="filed">
                        {{d.config_name}}
                    </script>

                    <script type="text/html" id="type">
                        {{#  if(d.type == 'text'){ }}<span style="color: #FFB800;">普通文本框</span>{{#  } }}
                        {{#  if(d.type == 'r_textarea'){ }}<span style="color: #FF5722;">富文本域</span>{{#  } }}
                        {{#  if(d.type == 'textarea'){ }}<span style="color: #1E9FFF;">多行文本域</span>{{#  } }}
                        {{#  if(d.type == 'checkbox'){ }}<span style="color: #5FB878;">复选框</span>{{#  } }}
                        {{#  if(d.type == 'radio'){ }}<span style="color: #FFB800;">单选框</span>{{#  } }}
                        {{#  if(d.type == 'select'){ }}<span style="color: #FF5722;">下拉框</span>{{#  } }}
                        {{#  if(d.type == 'upload'){ }}<span style="color: #1E9FFF;">文件上传</span>{{#  } }}
                    </script>
                    <script type="text/html" id="tabtype">
                        {{#  if(d.tabtype == '1'){ }}<span style="color: #FFB800;">系统配置</span>{{#  } }}
                        {{#  if(d.tabtype == '2'){ }}<span style="color: #FF5722;">插件配置</span>{{#  } }}
                        {{#  if(d.tabtype == '3'){ }}<span style="color: #1E9FFF;">应用配置</span>{{#  } }}
                        {{#  if(d.tabtype == '4'){ }}<span style="color: #5FB878;">其他配置</span>{{#  } }}
                    </script>
                    <script type="text/html" id="status2">
                        <input type="checkbox"  name="status" value="{{d.id}}" templateType="{{d.status}}" lay-skin="switch" lay-text="显示|隐藏" lay-filter="state" {{ d.status == 0 ? 'checked' : '' }}>
                    </script>



                    <script type="text/html" id="barDemo">
                        {{#  if(d.member_id == 0&&d.scopes == 'member'){ }}
                        <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="editconfig" title="批量编辑">批量编辑</a>
                        {{#  } else { }}
                        <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="editconfig" title="编辑">编辑</a>
                        {{#  } }}
                        <!--<a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="addconfig" title="添加配置">添加配置</a>-->
                        <!--<a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="list" title="配置列表">查看配置列表</a>-->
                        {{#  if(d.member_id == 0){ }}
                        <a class="layui-btn layui-btn-primary layui-btn-xs" lay-event="del" title="删除">删除</a>
                        {{#  } else { }}
                        {{#  } }}


                    </script>



                </div>
            </div>
        </div>
    </div>
</div>
<script>

    var table;
    var laydate;
    var result = "";
    var form;
    var auth_status = '';
    var dtree;
    layui.use(['form', 'table','laydate','element'],function() {
        var element = layui.element;
        table = layui.table;
        form = layui.form;
        laydate = layui.laydate;
        reset()
        //监听工具条
        table.on('tool(templateList)', function(obj) {
            var data = obj.data;
            if (obj.event === 'del') {
                del(data.id);
            } else if (obj.event === 'edit') {
                edit(data.title,data.tab_id);
            }else if (obj.event === 'list') {
                //list(data.title,data.id);
            }else if (obj.event === 'addconfig') {
                addconfig(data.title,'all',data.tab_id);
            }else if (obj.event === 'editconfig') {
                addconfig(data.title,data.id);
            }
        });

        //监听单元格编辑
        table.on('edit(templateList)', function(obj){
            var value = obj.value //得到修改后的值
                ,data = obj.data //得到所在行所有键值
                ,field = obj.field; //得到字段
            $.ajax({
                url: "{:Url('setconfigshow')}",
                type:"post",
                data:{id:data.id,sort:value},
                async: false,
                success: function (data){
                    if(data != 'success'){
                        layer.msg('操作失败！请联系管理员或稍后再试。', {
                            icon: 5,
                            time: 1000
                        });
                    }else{
                        layer.msg('更新成功', {
                            icon: 6,
                            time: 1500
                        });
                    }
                }
            });

        });

        //触发tab事件
        element.on('tab(docDemoTabBrief)', function(elem){
            // location.hash = 'test='+ $(this).attr('lay-id');

            switch(elem.index) {
                case 0:
                    //全部
                    auth_status = '';
                    reload();
                    break;
                case 1:
                    //未审核
                    auth_status = '1';
                    reload();
                    break;
                case 2:
                    //已通过
                    auth_status = '2';
                    reload();
                    break;
                case 3:
                    //审核失败
                    auth_status = '3';
                    reload();
                    break;
                case 4:
                    //审核失败
                    auth_status = '4';
                    reload();
                    break;
            }
        });

        //日期范围
        var begin = laydate.render({
            elem: '#beginTime',
            type: 'datetime',
            format: 'yyyy-MM-dd HH:mm',
            btns: ['clear', 'confirm'],
            done: function(value, date){
                if(date.year){
                    end.config.min =  {
                        year : date.year,
                        month : date.month-1,
                        date : date.date,
                        hours : date.hours,
                        minutes : date.minutes,
                        seconds : 0
                    }
                }else{
                    end.config.min =  {
                        year : 1970,
                        month : 1,
                        date : 1,
                        hours :23,
                        minutes : 59,
                        seconds : 59
                    }
                }
            }
        });
        var end = laydate.render({
            elem: '#endTime',
            type: 'datetime',
            format: 'yyyy-MM-dd HH:mm',
            btns: ['clear', 'confirm'],
            done: function(value, date){
                if(date.year){
                    begin.config.max = {
                        year : date.year,
                        month : date.month-1,
                        date : date.date,
                        hours : date.hours,
                        minutes : date.minutes,
                        seconds : 0
                    }
                }else{
                    begin.config.max = {
                        year : 2099,
                        month : 12,
                        date : 31,
                        hours : 59,
                        minutes : 59,
                        seconds:59
                    }
                }
            }
        });

        form.render("select");

        form.on('switch(state)', function(obj){
            tipText = "操作成功";
            var emelment = $('.layui-form-switch');

            if(isClick){
                isClick = false;
                var templateType = this.getAttribute("templateType");
                setBoxState(this.value,templateType,true);

                if(result != 'success'){
                    layer.msg('操作失败！请联系管理员或稍后再试。', {
                        icon: 5,
                        time: 1000
                    });
                }else{
                    layer.msg(tipText, {
                        icon: 6,
                        time: 1500
                    });
                }
                for (var i = 0; i < emelment.length; i++) {
                    $(emelment[i]).addClass('layui-disabled');
                    $(emelment[i]).unbind();
                }
                setTimeout(function(){
                    isClick = true;
                    curr = $('.layui-laypage-em').next().text();
                    reload();
                },1500);
            }else{
                layer.msg('请不要操作太频繁！', {
                    icon: 5,
                    time: 1000
                });
            }
        });

    });

    //设置推荐
    function setBoxState(id,templateType,state){

        $.ajax({
            url: "{:Url('setconfigshow')}",
            type:"post",
            data:{id:id,state:state,status:templateType},
            async: false,
            success: function (data){
                result = data;
            }
        });
    }

    //获取所选中的ID
    function getCheckData(){
        var checkStatus = table.checkStatus('templateList'), data = checkStatus.data;
        var obj = [];
        for (var i = 0; data.length > i; i++) {
            obj.push(data[i].id);
        }
        layer.alert(JSON.stringify(obj));
    }
    //获取重载列表
    function reload(){
        // var beginTime = $("#beginTime").val();
        // var endTime = $("#endTime").val();
        var status = $('#status').val();
        var info = $('#info').val();
        var id = $('#id').val();
        var config_name = $('#config_name').val();
        var scopes = $('#scopes').val();
        var member_ids = $('#member_ids').val();
        var nickname = $('#nickname').val();
        var tab_id =null;
        var miniapp_name = $('#miniapp_name').val();
        if(document.getElementById("tab_id")){
            tab_id = $('#tab_id').val();
        }
        table.reload('templateList', {
            where: { //设定异步数据接口的额外参数
                status: status
                // ,beginTime: beginTime
                // ,endTime: endTime
                ,type: auth_status
                ,info: info
                ,scopes:scopes
                ,id: id
                ,tab_id: tab_id
                ,config_name: config_name
                ,member_id: member_ids
                ,nickname: nickname
                ,dir:miniapp_name

            },page: {curr: 1}
        });
    }
    //重置
    function reset(){
        if(document.getElementById("config_name")) {
            document.getElementById("config_name").value = '';
        }
        // document.getElementById("beginTime").value = '';
        // document.getElementById("endTime").value = '';
        if(document.getElementById("tab_id")){
            document.getElementById("tab_id").value = '';
        }
        if(document.getElementById("id")){
            document.getElementById("id").value = '';
        }
        document.getElementById("info").value = '';
        document.getElementById("status").value = '';
        document.getElementById("scopes").value = '';
        document.getElementById("member_ids").value = '';
        document.getElementById("nickname").value = '';
        document.getElementById("miniapp_name").value = '';
        // document.getElementById("category_id").value = '';
        //执行清空
        // $("#templateType").empty();
        form.render("select");
        //render();
        table.reload('templateList', {
            where: { //设定异步数据接口的额外参数
                status: null
                // ,beginTime: beginTime
                // ,endTime: endTime
                ,type: auth_status
                ,info: null
                ,tab_id: null
                ,scopes: null
                ,id: null
                ,config_name: null
                ,member_id: null
                ,nickname: null
                ,dir: null
            },page: {curr: 1}
        });
    }

    //新增或修改

    function edit(version,id){
        var currentPage = $('.layui-laypage-em').next().text();
        var title = version + "查看";
        var url = "{:Url('edit')}?id="+id;
        var post_url = "{:Url('edit')}";
        if(id=='all'){
            title ='新增';
            url = "{:Url('add')}";
            post_url = "{:Url('add')}";
        }
        layer.open({
            type: 2,
            title: title,
            shade: 0.2,
            maxmin: true,
            area: ['90%','90%'],
            content: url,
            btn: ['立即提交'],
            yes: function(index, layero){

                var nodeName = window["layui-layer-iframe" + index];
                var id = nodeName.getId();
                var Data = nodeName.getSaveData();


                isClick = false;

                if(Data!= false){
                    $.ajax({
                        url: post_url,
                        type:"post",
                        data:Data,
                        success: function (data) {
                            //console.log(data.status);
                            if(data.data.errcode == 0){
                                layer.close(index);
                                layer.msg('处理中...',{shade:[0.2, '#393D49'],time:60*60*2000});
                                layer.msg('提交成功', {
                                    icon: 6,
                                    time: 1000 //1.5秒关闭（如果不配置，默认是3秒）
                                });
                                setTimeout(function(){
                                    isClick = true;
                                    layer.close(index);
                                    if(id != null && id != ''){
                                        curr = currentPage;
                                        reload();
                                    }else{
                                        reset();
                                    }
                                },1500);
                            }else if(data.data.errcode != 0){
                                layer.msg(data.msg, {
                                    icon: 5,
                                    time: 1500 //1.5秒关闭（如果不配置，默认是3秒）
                                });
                                isClick = true;
                            }else{
                                layer.msg('操作失败！请稍后再试。', {
                                    icon: 5,
                                    time: 1500 //1.5秒关闭（如果不配置，默认是3秒）
                                });
                                isClick = true;
                            }
                        }
                    });
                }


            }
        });
    }

    //新增或修改

    function addconfig(version,id,tab_id){
        var currentPage = $('.layui-laypage-em').next().text();
        var title = version + "查看";
        var url = "{:Url('editconfig')}?id="+id+"&tab_id="+tab_id;
        var post_url = "{:Url('editconfig')}";
        if(id=='all'){
            title ='新增';
            url = "{:Url('addconfig')}?tab_id="+tab_id;
            post_url = "{:Url('addconfig')}";
        }
        layer.open({
            type: 2,
            title: title,
            shade: 0.2,
            maxmin: true,
            area: ['90%','90%'],
            content: url,
            btn: ['立即提交'],
            yes: function(index, layero){

                var nodeName = window["layui-layer-iframe" + index];
                var id = nodeName.getId();
                var Data = nodeName.getSaveData();
                isClick = false;
                if(Data!= false){
                    $.ajax({
                        url: post_url,
                        type:"post",
                        data:Data,
                        success: function (data) {
                            console.log(data);
                            if(data.data.errcode == 0){
                                layer.close(index);
                                layer.msg('处理中...',{shade:[0.2, '#393D49'],time:60*60*2000});
                                layer.msg('提交成功', {
                                    icon: 6,
                                    time: 1000 //1.5秒关闭（如果不配置，默认是3秒）
                                });
                                setTimeout(function(){
                                    isClick = true;
                                    layer.close(index);
                                    if(id != null && id != ''){
                                        curr = currentPage;
                                        reload();
                                    }else{
                                        reset();
                                    }
                                },1500);
                            }else if(data.data.errcode != 0){
                                layer.msg(data.msg, {
                                    icon: 5,
                                    time: 1500 //1.5秒关闭（如果不配置，默认是3秒）
                                });
                                isClick = true;
                            }else{
                                layer.msg('操作失败！请稍后再试。', {
                                    icon: 5,
                                    time: 1500 //1.5秒关闭（如果不配置，默认是3秒）
                                });
                                isClick = true;
                            }
                        }
                    });
                }

            }
        });
    }
    function getLocalTime(nS) {
        return new Date(parseInt(nS) * 1000).toLocaleString().replace(/年|月/g, "-").replace(/日/g, " ");
    }

    var isClick = true;
    //删除
    function del(id){
        var ids = new Array();
        if(id == 'all'){
            var checkStatus = table.checkStatus('templateList');
            var data = checkStatus.data;
            if(data == 0){
                layer.alert('请选择');
                return;
            }
            for (var i = 0; i < data.length; i++) {
                ids[i] = data[i].id;
            }
        }else{
            ids[0] = id;
        }
        if(isClick){
            layer.confirm('真的要删除么', function(index) {
                isClick = false;
                layer.close(index);
                $.ajax({
                    url: "{:Url('configsoftdleting')}",
                    type:"post",
                    data:{"ids":ids.toString()},
                    success: function (data) {
                        layer.close(index);
                        if(data == 'success'){
                            layer.msg('删除成功', {
                                icon: 6,
                                time: 1500 //1.5秒关闭（如果不配置，默认是3秒）
                            });
                            setTimeout(function(){
                                isClick = true;
                                reload();
                            },1500);
                        }else if(data == 'nullValueFail'){
                            isClick = true;
                            layer.msg('操作失败！请联系管理员。', {
                                icon: 5,
                                time: 1500 //1.5秒关闭（如果不配置，默认是3秒）
                            });
                        }else if(data == 'paramFail'){
                            isClick = true;
                            layer.msg('操作失败！请删除分类下所有配置再重试。', {
                                icon: 5,
                                time: 1500 //1.5秒关闭（如果不配置，默认是3秒）
                            });
                        }else{
                            isClick = true;
                            layer.msg('未知错误。', {
                                icon: 5,
                                time: 1500 //1.5秒关闭（如果不配置，默认是3秒）
                            });
                        }
                    },error : function(){

                    }
                });
            });
        }
    }

    //显示大图片
    function show_img(t) {
        var t = $(t).find("img");
        //页面层
        layer.open({
            type: 1,
            title: '',
            //skin: 'layui-layer-rim', //加上边框
            area: ['80%', '80%'], //宽高
            shadeClose: true, //开启遮罩关闭
            end: function (index, layero) {
                return false;
            },
            content: '<div style="text-align:center"><img src="' + $(t).attr('src') + '" height="40%" width="40%" /></div>'
        });
    }

    //根据分类id获取分类名称
    function getCategoryName(id) {
        var json = '{category_json}';
        json = HTMLDecode(json);//html反转移
        var obj = JSON.parse(json);//json解析成对象
        for(let k in obj) {
            if(k == id){
                return obj[k];
            }
        }
        return '无分类';
    }
    function HTMLDecode(text) {
        var temp = document.createElement("div");
        temp.innerHTML = text;
        var output = temp.innerText || temp.textContent;
        temp = null;
        return output;
    }

</script>
{/block}